var document = this.document

const types = {
  type: 'FORBIDDEN_FILTER_XJ_CUSTOM_MADE',
  icon: 'https://ocean.codemao.cn/appcraft/resource/icon/媒体/图片.svg',
  title: '定制-禁用滤镜',
  version: '1.0.0',
  author: 'XJ王大哥(2357942846)',
  isInvisibleWidget: true,
  isGlobalWidget: true,
  properties: [],
  methods: [
    {
      key: 'addFilter',
      label: '添加滤镜',
      params: [{key: 'ID',label: '控件ID',valueType: 'string',defaultValue: ""},{key: 'level',label: '灰度',labelAfter: '%',valueType: 'number',defaultValue: 100}],
      blockOptions: {callMethodLabel: false}
    },
    {
      key: 'removeFilter',
      label: '删除滤镜',
      params: [{key: 'ID',label: '控件ID',valueType: 'string',defaultValue: ""}],
      blockOptions: {callMethodLabel: false}
    },
  ],
  events: [],
}

class Widget extends InvisibleWidget {
  constructor(props) {super(props)}
  addFilter = (ID, level) => document.getElementById(ID).style.filter = `grayscale(${level}%)`
  removeFilter = (ID) => document.getElementById(ID).style.removeProperty('filter')
}

exports.types = types
exports.widget = Widget